// 初始化数据
export const initState = {
  // 订单列表
  info: {username: 'Jay'}
}

// 统一处理action的type
const type = {
  CHANGEINFO: 'changeInfo'
}

// 统一处理action，这里会生成所有的action
export const actions = {
  changeInfo: (info) => ({type: type.CHANGEINFO, info})
}

export const reducer = (state = initState, action)=> {
  switch (action.type) {
    case type.CHANGEINFO:
      return {
        ...state,
        info: action.info
      }
    default:
      return state
  }
}

export const getInfo = (state) => (state.user.info);
export default reducer;